The Slider Component > Using the Slider component > Creating an application with the Slider component

 

Creating an application with the Slider component

The following procedure describes how to create a simple application with the Slider component. In this procedure, you enter simple ActionScript code to find the current value of the component. For more complex examples, see Examples for the Slider component.

 
To create a simple application using the Slider component:

1

Open Macromedia Flash MX.

2

Open the Components panel (Window > Components).

3

Select Flash UI Components Set 5 from the Components panel menu.

4

Drag an instance of the Slider component onto the stage.

5

Set the instance name of the Slider to mySlider_sld.

6

Set the change handler in the Property Inspector for the Slider to be onSliderChange.

7

Add a new layer to the main timeline and name it actions.

8

Select the new layer and open the Actions panel (Window > Actions).

9

In the Actions panel add the following code:

/*
* define a function to be called when the value of the
* slider changes
*/
function onSliderChange()
{
	var sliderValue = mySlider_sld.getIntValue();
	trace("Slider Value : " + sliderValue);
}


//tell the slider which function to call when the value changes
mySlider_sld.setChangeHandler("onSliderChange");

10

Save, publish, and test the movie. When you move the slider, the current value will be traced to the output window.

You can view the code for this example in the slider_simple_example.fla example file.